<!DOCTYPE html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>农产品价格分析预测系统</title>
    <link rel="stylesheet" href="../static/css/index.css" />
    <script src="{{ url_for('static',filename='js/echarts.js')}}"></script>
    <link rel="stylesheet" href="{{ url_for('static',filename='css/style.css')}}">
        <!-- 引入本地的 jQuery -->
    <script src="../static/js/jquery.min.js"></script>
    <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/formcss.css') }}">
</head>
<body style="margin: 0;">
    <div style="border-top: 50px solid #428bca;"></div>
    <div id="datetime" style="text-align: center; color: lightcyan; margin-top: -1.7%;margin-left: 5%;font-weight: bold;font-size:25px;"></div>

    <div style="text-align: center; color: white; font-size: 30px;margin-top: 30px;margin-left: 5%">价格变化情况滚动表</div>

    <script src="{{ url_for('static',filename='js/time.js')}}"></script>



    <!-- 侧边栏 -->
    <div class="sidebar" style="z-index: 99">
        <div style="position: relative; border-top: 50px solid #428bca;">
            <div style="position: absolute; top: -40px; left: 0px; right: 0; text-align: center; color: white; font-size: 25px;">数据可视化</div>
        </div>
        <a href="/index" style="display: block; text-align: center; ">数据总览</a>
        <a href="/chart" style="display: block; text-align: center; ">产品分析</a>
        <a href="/chart1" style="display: block; text-align: center; ">价格变化趋势折线图</a>
        <a href="/chart2" style="display: block; text-align: center; ">价格变化情况滚动表</a>
        <a href="/chart3" style="display: block; text-align: center; ">价格变化柱状图</a>
        <a href="/chart4" style="display: block; text-align: center; ">价格对比雷达图</a>
        <a href="/chart5" style="display: block; text-align: center; ">最低价变化饼图</a>
        <a href="/predict" style="display: block; text-align: center; ">未来7日价格预测</a>
        <a href="/products" style="display: block; text-align: center; ">产品管理(管理员)</a>
        <a href="/manage" style="display: block; text-align: center; ">用户管理(管理员)</a>
        <a href="/register" style="display: block; text-align: center; ">用户注册</a>
        <a href="/login" style="display: block; text-align: center; ">切换用户</a>
    </div>

    <center>
 <!-- 地图模块 -->
        <div class="map" style="width:90%;height:800px;margin-left: 5%;">
          <div class="map1"></div>
          <div class="map2"></div>
          <div class="map3"></div>
          <div class="chart"></div>
        </div>
        <!-- 农产品查询表单 -->
        <div style="text-align: center; bottom: 20px; position: absolute; margin-left: 41%; ">
            <form id="form" name="form" method='POST' action='/chart2' style="display: inline-block; text-align: left;">
                <h1 style="color: white;">请输入农产品名：
                <input type="text" name="product" placeholder="例：北方江米" style="height:50px;width:160px;font-size:25px;">
                    <input type="submit" value="点击查询">
                </h1>
            </form>
        </div>
            </center>
            <div class="tablebox" style=" position: absolute; top: 18%; left: 30%;opacity: 0.7;">

                <div class="tbl-header" >
                    <table border="0" cellspacing="0" cellpadding="0">
                        <thead style="opacity: 1;">
                            <tr>
                                <th>日期</th>
                                <th>最低价(元)</th>
                                <th>最高价(元)</th>
                                <th>日均价(元)</th>
                            </tr>
                        </thead>
                        <tbody style="opacity:0;"></tbody>
                    </table>
                </div>
                <div class="tbl-body">
                    <table border="0" cellspacing="0" cellpadding="0">
                        <thead >
                            <tr>
                                <th>日期</th>
                                <th>最低价(元)</th>
                                <th>最高价(元)</th>
                                <th>日均价(元)</th>
                            </tr>
                        </thead>
                        <tbody></tbody>
                    </table>
                </div>
            </div>



    <script>
        $(document).ready(function() {
            var Items = {{dict_return['data_tb']|tojson}};
            var str = '';
            $.each(Items, function (i, item) {
                str += '<tr>' +
                    '<td>' + item.date + '</td>' +
                    '<td>' + item.low_price + '</td>' +
                    '<td>' + item.high_price + '</td>' +
                    '<td>' + item.price + '</td>' +
                    '</tr>';
            });
            $('.tbl-body tbody').append(str);
            $('.tbl-header tbody').append(str);

            if (Items.length > 5) {
                $('.tbl-body tbody').html($('.tbl-body tbody').html() + $('.tbl-body tbody').html());
                $('.tbl-body').css('top', '0');
                var tblTop = 0;
                var speedhq = 50; // 数值越大越慢
                var outerHeight = $('.tbl-body tbody').find("tr").outerHeight();
                var MyMarhq = setInterval(Marqueehq, speedhq);

                $(".tbl-header tbody").hover(function () {
                    clearInterval(MyMarhq);
                }, function () {
                    clearInterval(MyMarhq);
                    MyMarhq = setInterval(Marqueehq, speedhq);
                });

                function Marqueehq() {
                    if (tblTop <= -outerHeight * Items.length) {
                        tblTop = 0;
                    } else {
                        tblTop -= 1;
                    }
                    $('.tbl-body').css('top', tblTop + 'px');
                }
            }
        });
            window.addEventListener('resize', myChart.resize);
    </script>
</body>
</html>
